package com.tfswx.jcyw.sqlmodel.web;

import cn.hutool.core.net.NetUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
import org.springframework.context.event.EventListener;

import java.util.LinkedHashSet;
import java.util.Set;

@Slf4j
@SpringBootApplication
public class SqlModelApplication {

    public static void main(String[] args) {
        SpringApplication.run(SqlModelApplication.class, args);
    }

    @EventListener(ServletWebServerInitializedEvent.class)
    public void handleServletWebServerInitializedEvent(ServletWebServerInitializedEvent event) {
        Set<String> ipSet = NetUtil.localIpv4s();
        int port = event.getWebServer().getPort();

        System.out.println("========地址信息===========================");
        System.out.println("\t\t====文档====");
        for (String ip : ipSet) {
            System.out.println("\t\thttp://" + ip + ":" + port + "/doc.html");
        }
    }
}
